﻿@model IEnumerable<FShare.ViewModels.UploadedFileViewModel>
@{
    ViewBag.Title = "FileManagement";
}

<h2>FileManagement</h2>

<div class="admin-container">
    <table class="admin-table">
        <tr>
            <td class="admin-left-sidebar">
                @Html.Partial(FShare.Helpers.Constants.ADMIN_LEFT_NAVIGATION_MENU_NAME)
            </td>
            <td class="admin-main-content">
                <div class="search-area">
                    @using (Html.BeginForm("FileManagement", "Administrator"))
                    {
                        <span>Search:</span>
                        <input type="text" name="searchbox" id="searchbox" />
                        <input type="submit" value="Search" />
                    }
                </div>
                <table>
                    <colgroup>
                        <col />
                        <col />
                        <col />
                        <col />
                        <col />
                        <col />
                    </colgroup>
                    <thead>
                        <tr>
                            <th>Uploader</th>
                            <th>File name</th>
                            <th>Description</th>
                            <th>Date uploaded</th>
                            <th>Downloads</th>
                            <th>Control</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var file in Model)
                        {
                        <tr>
                            <td class="file-uploader">
                            @if (!string.IsNullOrEmpty(file.UploaderUserName)) 
                            {
                                <span>@Html.ActionLink(file.UploaderUserName, "FileManagement", "Administrator", new { id = file.UploaderUserName }, null)</span>
                            }
                            </td>
                            <td class="file-name">@file.FileName</td>
                            <td class="file-description">@file.Description</td>
                            <td class="file-upload-time">@file.UploadedTime.ToShortDateString()</td>
                            <td class="file-download-times">@file.NumberOfDownloads</td>
                            <td class="file-control">
                                [@Html.ActionLink("Delete", "Delete", "Files", new { id = file.DeleteSecret }, null)]
                                [@Html.ActionLink("Download", "Download", "Files", new { id = file.DownloadSecret }, null)]
                            </td>
                        </tr>
                        }
                    </tbody>
                </table>
            </td>
        </tr>
    </table>
</div>